import {LogLanguage} from "../dist/index.js"

// 测试参数类型识别
const testCases = [
  // 不同类型的参数
  "Parameters: points_package_id(String)",
  // 数字开头的参数
  "Parameters: 17688834922(String)",
  "Parameters: user_id(Long)",
  "Parameters: amount(Integer)",
  "Parameters: is_active(Boolean)",
  "Parameters: price(Double)",
  "Parameters: created_at(Date)",
  "Parameters: description(Text)",
  "Parameters: status(Enum)",
  "Parameters: config(Map)",
  "Parameters: tags(List)",
  
  // 混合格式
  "2024-01-15 10:30:45 [INFO] Parameters: user_id(Long) points_package_id(String) amount(Integer)",
  
  // 复杂日志行
  "2025-08-06 11:23:02,220 INFO [TID:] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] points.PointsProcessor (com.cn.yft.ora.bank.p600030.points.PointsProcessor:64) - Parameters: user_id(Long) points_package_id(String) amount(Integer) is_active(Boolean)"
]

console.log("=== 参数类型识别测试 ===")

testCases.forEach((testCase, index) => {
  console.log(`\n测试 ${index + 1}:`)
  console.log(`输入: ${testCase}`)
  
  // 检查参数类型识别
  // 使用与src/index.ts中相同的正则表达式，支持数字开头的参数名
  const paramTypeRegex = /\b([a-zA-Z0-9_]+)\s*\(([A-Z][a-zA-Z]*)\)/g
  let match
  let foundParams = []
  
  while ((match = paramTypeRegex.exec(testCase)) !== null) {
    const fullMatch = match[0]  // 完整匹配
    const paramName = match[1]  // 参数名
    const paramType = match[2]  // 参数类型
    const from = match.index
    const to = from + fullMatch.length
    const cssClass = `cm-sql-param-type-${paramType}`
    
    foundParams.push({
      full: fullMatch,
      paramName: paramName,
      paramType: paramType,
      from: from,
      to: to,
      cssClass: cssClass
    })
  }
  
  if (foundParams.length > 0) {
    console.log("✓ 参数类型识别成功:")
    foundParams.forEach(param => {
      console.log(`  - 完整匹配: "${param.full}"`)
      console.log(`  - 参数名: "${param.paramName}"`)
      console.log(`  - 参数类型: "${param.paramType}"`)
      console.log(`  - 高亮范围: ${param.from}-${param.to}`)
      console.log(`  - CSS类名: "${param.cssClass}"`)
      
      // 验证CSS类名格式
      const expectedClass = `cm-sql-param-type-${param.paramType}`
      if (param.cssClass === expectedClass) {
        console.log(`  ✓ 正确: CSS类名格式正确 "${param.cssClass}"`)
      } else {
        console.log(`  ✗ 错误: CSS类名格式错误 "${param.cssClass}"`)
      }
    })
  } else {
    console.log("✗ 未找到参数类型")
  }
})
